﻿/********************************************************************************************************************
* Author:	Christos Polydorou																						*
* Email:	std04237@di.uoa.gr																						*
* Purpose:	This script is used in order to create the "Users" table that holds all users.							*
********************************************************************************************************************/

CREATE TABLE [dbo].[Users]
(
	ID bigint PRIMARY KEY NOT NULL IDENTITY(1,1),						/* Identity of the user */ 
	Username nvarchar(50) NOT NULL UNIQUE,								/* The username */
	Password nvarchar(50) NOT NULL,										/* User's password */
	Email nvarchar(50) NOT NULL UNIQUE,									/* User's email address */
	Usertype nvarchar(3) NOT NULL DEFAULT('std'),						/* The type of the user (eg admin,std) */
	IsEnabled int DEFAULT (0) NOT NULL,									/* 0 if user is enabled */
	TimeLocked datetime NOT NULL,										/* the time when user was locked */
	LoginAttempts int NOT NULL DEFAULT(0),								/* the number of attempts the user tried to log in */
	LastLogin datetime NOT NULL	,										/* the time when the user last logged in */
	DateCreated datetime NOT NULL,										/* the date the user was created */
	fname nvarchar(50),
	lname nvarchar(50)
)
